package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-22 13:36
 * @Modified By:
 */
public class MaxCount_598 {
    public static void main(String[] args){
        int [][] operations = new int[][]{{2,2},{3,3}};
        System.out.println(maxCount(3,3,operations));
    }

    public static int maxCount(int m, int n,int[][] ops){
        int[][] initialArr = new int[m][n];
        for (int i = 0; i < ops.length; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < ops[i][j]; k++) {
                    for (int l = 0; l < ops[i][j+1]; l++) {
                        initialArr[k][l]++;
                    }
                }
                j++;
            }
        }
        int result = 0;
        int max = findMax(initialArr);
        for (int[] ints : initialArr) {
            for (int anInt : ints) {
                if (anInt == max){
                    result++;
                }
            }
        }
        return result;
    }

    public static int findMax(int[][] nums){
        int max = 0;
        for (int[] num : nums) {
            for (int i : num) {
                if (i > max){
                    max = i;
                }
            }
        }
        return max;
    }
}
